package com.poh.service.impl;

import com.poh.mapper.SUMapper;
import com.poh.pojo.SU;
import com.poh.service.SUService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.time.LocalDate;
import java.time.LocalTime;
import java.time.format.DateTimeFormatter;
import java.util.List;
@Service
public class SUServiceImpl implements SUService {
    @Autowired
    SUMapper suMapper;
    @Override
    public int addSU(SU su) {
        return suMapper.addSU(su);
    }

    @Override
    public List<SU> querySUByUserIdAndCourseId(int userId, int courseId) {
        return suMapper.querySUByUserIdAndCourseId(userId, courseId);
    }

    @Override
    public SU querySUBySIdAndUserId(String sId, int userId) {
        return suMapper.querySUBySIdAndUserId(sId, userId);
    }

    @Override
    public int updateSUStudentSingInStatus(String sId, int userId, int status) {
        LocalDate localDate = LocalDate.now();
        LocalTime localTime = LocalTime.now();
        return suMapper.updateSUStudentSingInStatus(sId, userId, localDate.format(DateTimeFormatter.ISO_DATE) + " " + localTime, status);
    }

    @Override
    public List<SU> querySingInStuBySid(String sId) {
        return suMapper.querySingInStuBySid(sId);
    }

    @Override
    public int getCountSingIn(String sId, int stuSingInStatus) {
        return suMapper.getCountSingIn(sId, stuSingInStatus);
    }

    @Override
    public int getCountMySingIn(int userId, int courseId, int singInStatus) {
        return suMapper.getCountMySingIn(userId, courseId, singInStatus);
    }


}
